﻿using System;
using System.Net.Mime;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;

namespace WebServer
{
	/// <summary>
	/// A simple HTML-coded element for use with WebObjects
	/// </summary>
	public sealed class HTMLElement : WebObjectElement
	{
		/// <summary>
		/// Constructs an instance of HTMLElement attached to the given parent WebObject with the given HTML-code
		/// </summary>
		/// <param name="parent">Parent WebObject instance</param>
		/// <param name="html">HTML-code to display</param>
		public HTMLElement(IWebObject parent, string html)
			: base(parent, "html", "html")
		{
			AddHTML(html);
		}
	}

	/// <summary>
	/// A simple plain-text element for use with WebObjects
	/// </summary>
	public sealed class TextElement : WebObjectElement
	{
		/// <summary>
		/// Constructs an instance of TextElement attached to the given parent WebObject with the given text
		/// </summary>
		/// <param name="parent">Parent WebObject instance</param>
		/// <param name="text">Text to display</param>
		public TextElement(IWebObject parent, string text)
			: base(parent, "text", "text")
		{
			AddHTML(text);
		}
	}

	/// <summary>
	/// A simple plain-text element for use with WebObjects
	/// </summary>
	public sealed class ByteElement : WebObjectElement
	{
		/// <summary>
		/// Constructs an instance of ByteElement attached to the given parent WebObject with the given byte data
		/// </summary>
		/// <param name="parent">Parent WebObject instance</param>
		/// <param name="b">Byte data</param>
		public ByteElement(IWebObject parent, byte b)
			: base(parent, "byte", "byte")
		{
			AddByte(b);
		}

		/// <summary>
		/// Constructs an instance of ByteElement attached to the given parent WebObject with the given byte data
		/// </summary>
		/// <param name="parent">Parent WebObject instance</param>
		/// <param name="bytes">Byte data</param>
		public ByteElement(IWebObject parent, byte[] bytes)
			: base(parent, "bytes", "bytes")
		{
			AddByte(bytes);
		}
	}
}
